const mongoose = require('mongoose')

const schema = new mongoose.Schema({
    name: {
        type: String,
        required: true
    },
    account: {
        type: String,
        required: true,
    },
    password: {
        type: String,
        required: true,
        set(val){
            // 进行散列加密
            return require('bcrypt').hashSync(val, 10)
        }
    },
    //角色权限分类
    type: {
        type: mongoose.SchemaTypes.ObjectId,
        ref: 'UserType'
    }
})

module.exports = mongoose.model('UserAdmin', schema)